class code1 {
    //首位指针交换
    public int removeElement(int[] nums, int val) {
        int right = nums.length-1;
        for(int left = 0;left<=right;left++) {
            if(nums[left] == val) {
                int tmp = nums[left];
                nums[left] = nums[right];
                nums[right] = tmp;
                left--;
                right--;
            }
        }
        return right+1;
    }
}